﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace Playlist_file_loader.Core
{
    class ErrorLogUpdater
    {
        //-------------------------------------------------------------------//
        //-------------------------member variables--------------------------//
        //-------------------------------------------------------------------//

        public delegate void ListBoxAdder(ErrorMsg errMsg);
        public ListBoxAdder methodAddItemToListBox;

        static private System.Windows.Forms.ListBox m_lstBox;

        //-------------------------------------------------------------------//
        //-------------------------function definitions----------------------//
        //-------------------------------------------------------------------//



        //-------------------------------------------------------------------//
        // Description: constructor
        public ErrorLogUpdater()
        {
            methodAddItemToListBox = new ListBoxAdder(Update);
        }

        //-------------------------------------------------------------------//
        // Description: 
        public void ConnectListBox(System.Windows.Forms.ListBox lstBox)
        {
            m_lstBox = lstBox;
        }

        //-------------------------------------------------------------------//
        // Description: 
        public static void Update(ErrorMsg errMsg)
        {
            if (null != m_lstBox)
            {
                // Add error to lstBox;
                m_lstBox.Items.Add(errMsg.GetErrString());
            }
        }

    }
}
